Skip to content

fix: serialize configure locator updates#416

Open
karthiknadig wants to merge 5 commits intomainfrom
bug/issue-385
Open

fix: serialize configure locator updates#416
karthiknadig wants to merge 5 commits intomainfrom
bug/issue-385

Conversation

@karthiknadig
Copy link
Copy Markdown
Member

Summary:

  • Apply configure updates and long-lived locator reconfiguration under the same configuration write lock.
  • Keep refresh-state sync from interleaving with shared locator reconfiguration.
  • Add a regression test that blocks locator configuration and verifies configuration readers cannot observe the new state early.

Validation:

  • cargo test -p pet test_configure_publishes_state_after_shared_locators_are_configured
  • cargo test -p pet jsonrpc::tests::test_
  • cargo fmt --all
  • cargo clippy --all -- -D warnings

Fixes #385

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Performance Report (Linux) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 78ms 130ms 96ms -18ms -10.0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 73.7%
Base Branch Coverage 73.6%
Delta .1% ✅

Coverage increased! Great work!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 79ms 679ms 58ms 21ms
Full Refresh 133ms 35037ms 99ms 34ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@karthiknadig karthiknadig requested a review from Copilot April 12, 2026 06:36
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Performance Report (Windows) ➖

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 10ms 13ms 8ms 2ms 25%
Full Refresh 171ms 467ms 128ms 43ms 33.6%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 70.01%
Base Branch Coverage 69.86%
Delta 0.15% ✅

Coverage increased! Great work!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a race between configure and refresh by ensuring configuration publication and long-lived shared locator reconfiguration occur under the same Context.configuration write lock, preventing refresh-related state sync from interleaving with locator reconfiguration.

Changes:

  • Refactors handle_configure() to apply config updates + shared locator reconfiguration atomically via a new apply_configure_options() helper.
  • Ensures shared locator reconfiguration happens while holding the configuration write lock to prevent readers observing partially-applied state.
  • Adds a regression test that blocks inside a locator’s configure() to verify configuration readers can’t observe the new generation/config early.
Show a summary per file
File Description
crates/pet/src/jsonrpc.rs Serializes configure publication and shared locator reconfiguration under the configuration write lock; adds regression coverage for the race.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a concurrency race between configure and refresh-related operations by serializing shared locator reconfiguration with configuration publication, ensuring refreshes observe a coherent configuration boundary (Fixes #385).

Changes:

  • Refactors handle_configure() to apply configuration updates and reconfigure long-lived shared locators under the same configuration write lock.
  • Introduces apply_configure_options() to centralize configure-state mutation + shared locator configuration.
  • Adds a regression test to ensure configuration readers cannot observe the new configuration state before shared locators have been fully reconfigured.
Show a summary per file
File Description
crates/pet/src/jsonrpc.rs Serializes configuration publication with shared locator configuration and adds a regression test guarding against early visibility.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Issue #385 by preventing configure and refresh from racing on shared locator configuration. It does this by ensuring locator reconfiguration and configuration-state publication occur under the same configuration write lock, so concurrent readers/refresh state sync can’t observe partially-applied configuration.

Changes:

  • Refactors configure handling to apply config updates and reconfigure long-lived shared locators under a single configuration write lock (apply_configure_options).
  • Adds panic-guarding + rollback attempt for locator configuration failures to avoid publishing partially-applied configuration.
  • Adds regression tests to verify configuration readers cannot observe the new configuration state before shared locators finish configuring.
Show a summary per file
File Description
crates/pet/src/jsonrpc.rs Serializes configure publication with shared-locator reconfiguration; adds rollback-on-panic behavior and regression tests for the locking boundary.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a correctness race in PET’s JSON-RPC server where configuration publication could interleave with shared locator reconfiguration / refresh-state sync, by serializing locator configuration with configuration state updates under the same configuration write lock.

Changes:

  • Refactors configure handling to apply configuration updates and shared locator reconfiguration atomically via a new apply_configure_options() helper.
  • Adds defensive panic handling + rollback attempts for locator configuration/caching setup, and introduces regression tests to validate publication ordering and panic behavior.
  • Adjusts a pet-virtualenvwrapper test to canonicalize a temp project root path for stable assertions.
Show a summary per file
File Description
crates/pet/src/jsonrpc.rs Serializes configure publication with shared locator reconfiguration; adds panic handling, rollback helper, and regression tests.
crates/pet-virtualenvwrapper/src/environments.rs Canonicalizes the test project_root path to align with path normalization behavior.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses the race in #385 where configure could publish a new configuration generation while shared, long-lived locators were still being reconfigured (and while refresh-state sync could interleave with that reconfiguration). It does so by applying configuration updates and shared-locator reconfiguration under the same ConfigurationState write lock, and adds regression tests to enforce the intended visibility boundary.

Changes:

  • Move configure’s “publish new config generation” step behind a new helper that holds the configuration write lock while configuring shared locators.
  • Add rollback + panic handling so a panicking locator configure() won’t publish partial configuration state.
  • Adjust a virtualenvwrapper test to canonicalize the project root path.
Show a summary per file
File Description
crates/pet/src/jsonrpc.rs Serializes configure publication with shared locator configuration; adds rollback/panic safety and regression tests for the locking boundary.
crates/pet-virtualenvwrapper/src/environments.rs Canonicalizes a test path to make .project path handling consistent.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new

@karthiknadig karthiknadig marked this pull request as ready for review April 13, 2026 02:38
@karthiknadig karthiknadig enabled auto-merge (squash) April 13, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: configure and refresh can race on shared locator configuration

2 participants